<?php



function bing_pic($mode){//bing每日一图，mode1=图片地址，mode2=图片介绍，mode3=输出原始json
	
$bing_0 = "https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1";
$Temp_0 = file_get_contents($bing_0);
$Pinfo_0 = json_decode($Temp_0);
$img_0 = $Pinfo_0->{"images"}[0]->{"url"};
$imgcopyright_0 = $Pinfo_0->{"images"}[0]->{"copyright"};
$imgurl_0 = "https://cn.bing.com".$img_0;

if($mode==1){ return	$imgurl_0; }elseif($mode==2){ return $imgcopyright_0; }elseif($mode==3){ return $Temp_0; }else return 0;

}



function run_sql( $sql , $mode = 0 ){//链接数据库    //mode=0或者不填返回$result     mode=1返回$mydb

	include('config.php');	
	
	$mydb = mysqli_connect($Config_DB_url,$Config_DB_username,$Config_DB_password,$Config_DB_dbname,$Config_DB_point);//链接数据库
	 
	if(!$mydb){
        die(mysqli_connect_error());//如果链接失败输出错误
    
	}
	
	if($mode == 1){
	 return $mydb; 
	}//mode=1返回$mydb
	
    mysqli_query($mydb,'SET NAMES UTF8');
	
	$result = mysqli_query($mydb,$sql);//执行sql
	
	mysqli_close($mydb);
	 
	return $result;
	
}




?>